//
//  LeftController.m
//  SizableExample
//
//

#import "LeftController.h"
@implementation LeftController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    
    dataListViewController = [[DataListViewController alloc] initWithStyle:UITableViewStylePlain];
    [dataListViewController.view setBounds:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height-55)];
    UITableView *tableView = dataListViewController.tableView;
    items = [[NSArray alloc] init];
    items = [[NSArray alloc] initWithObjects:@"The Big Bang Theory", @"Bref", @"Dexter", @"Norman fait des vidéos", @"Chuck", nil];

    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    tableView.backgroundColor = [UIColor clearColor];
       
    
    [self.view insertSubview:dataListViewController.view atIndex:0];
    
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}


- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(IBAction)left:(id)sender{
    NSLog(@"left");
    [self sendToController];
}

-(void)sendToController{
    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
    [appDelegate.viewController sendToCenter];
}








#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    NSString *link = [NSString stringWithFormat:@"objc:OO:serie:OO: %d", [indexPath row]];
    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
    [appDelegate href:link];
    
}






@end
